package org.zlb.netty.server.marshalling;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

public class MarshallingServerHandler extends ChannelInboundHandlerAdapter {

    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
            throws Exception {
        cause.printStackTrace();
    }
  
    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg)throws Exception {
        SendRequest send = (SendRequest) msg;
        System.out.println("client发送："+send);
         
        ReceiveResponse receive = new ReceiveResponse();
        receive.setId(send.getId());
        receive.setMessage(send.getMessage());
        receive.setName(send.getName());
        ctx.writeAndFlush(receive);
    }
}
